﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace VNSoft
{
    public partial class Default : System.Web.UI.Page
    {
        Administrator.clsXuLy ex = new Administrator.clsXuLy();
        public string Host = System.Configuration.ConfigurationSettings.AppSettings["Host"].ToString();
        DataTable dts;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                dts = ex.GetData("cl_GetBaiViet_SanPham");
                LoadBaiViet(dts, lbBaiViet,"phan-mem/");

                dts = ex.GetData("cl_GetBaiViet_DichVu");
                LoadBaiViet(dts, lbDichVu,"dich-vu/");            
            }
        }
        private void LoadBaiViet(DataTable dt, Label lb,string Tag)
        {
            lb.Text = "";
            try
            {
                if (dt.Rows.Count > 0)
                {

                    lb.Text += "<table>";

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        lb.Text += "<tr><td width=\"195px\" valign=\"top\">";
                        lb.Text += "<a href='" + Host + Tag + ex.ConvertToUnSign(dt.Rows[i]["Title"].ToString()) + "/" + dt.Rows[i]["ArticleID"].ToString().ToUpper() + ".html'" + ">";
                        lb.Text += "<img class=\"anh\" width=\"195px\" height=\"125px\" alt='" + dt.Rows[i]["Title"].ToString() + "' src='" + Host + dt.Rows[i]["Image"].ToString() + "' ";
                        if (i > 0)
                            lb.Text += " style=\"margin-top: 10px;\"";
                        lb.Text += " /></a></td><td valign=\"top\"><div class=\"title\"";
                        if (i > 0)
                            lb.Text += "style=\"margin-top: 5px;\">";
                        lb.Text += "<a href='" + Host + Tag + ex.ConvertToUnSign(dt.Rows[i]["Title"].ToString()) + "/" + dt.Rows[i]["ArticleID"].ToString().ToUpper() + ".html'>" + dt.Rows[i]["Title"].ToString() + "</a>";
                        lb.Text += "</div><div class=\"description\">";
                        lb.Text += dt.Rows[i]["Description"].ToString();
                        lb.Text += "</div></td></tr>";
                    }
                    lb.Text += "</table>";

                }
            }
            catch { lb.Text = ""; }
        }
    }
}